<?php
class User_Model_SidebarModule extends Zend_Db_Table{
	protected $_name = 'sidebar_module';
	protected $_primary = 'module_id';
	/* Link tham khao : http://framework.zend.com/manual/en/zend.db.table.html */
	/* select demo */
	/*public function selectModuleByCode($code)
	{
		$select = $this->select();
		$select->from('sidebar_module');
		$select->setIntegrityCheck(false);
		$select->where('module_code = ?', $code);
		$arr = $this->fetchAll($select);
		return $arr;
	}*/
	public function selectAllModule()
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/sidebarmodule/route/selectAllModule");
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];	
		return $data;		
	}	
		
	/* update demo */
	/*public function updateTempTable($id,$title,$content)
	{
		$adapter = $this->getDefaultAdapter();
		try {	
				$adapter->beginTransaction();
				$where = $adapter->quoteInto('id = ?', $id);
				$adapter->update('temp',array('title'=>$title,'content'=>$content),$where);
				$adapter->commit();
		}
		catch (Zend_Db_Table_Exception $e) {
			$adapter->rollBack();
			return -1;
		}
		return 1;
	}*/
	
	
	/* delete demo */
	/*public function deleteModuleByCode($code)
	{
		$adapter = $this->getDefaultAdapter();
		try {
			$adapter->beginTransaction();
			$where = $adapter->quoteInto('module_code = ?', $code);
			$adapter->delete('sidebar_module',$where);
			$adapter->commit();
		}
		catch (Zend_Db_Table_Exception $e) {
			$adapter->rollBack();
			return -1;
		}
		return 1;
	}
	*/
	
	/* insert demo */
	/*public function insertModule($data)
	{
		$adapter = $this->getDefaultAdapter();
		try {
			$adapter->beginTransaction();
			$adapter->insert('sidebar_module', $data);
			$adapter->commit();
		}
		catch (Zend_Db_Table_Exception $e) {
			$adapter->rollBack();
			return -1;
		}
		return 1;
	}*/
}